<div class="card">
    <div class="card-header">
        <div class="card-title">
            {% if searchField %}
                  <button class="btn btn-brown btn-sm search-btn-filter">
                      <i class="mdi mdi-filter"></i><span class="hidden-xs">查询</span>
                  </button>
                {% if gridBar %}
                    {% for gk, gv in gridBar %}
                        {% if gv['type'] == 'button' %}
                            <a href="{{ gv['url'] }}"  class="btn btn-sm btn-info {{ gv['class'] }}" title="{{ gk }}" {% if gv['isBlank'] %} target="_blank" {% endif %}>
                                <i class="{{ gv['iconCLass'] }}"></i><span class="hidden-xs">{{ gk }}</span>
                            </a>
                        {% endif %}
                    {% endfor %}
                {% endif %}
            {% endif %}
        </div>
    </div>
  {{ include("@Grid/search.html.twig", {'searchField':searchField}) }}
    <div class="card-body table-responsive .p-0">
        <table class="table table-hover text-nowrap">
            <thead>
            <tr>
              {% for cv in column %}
                {% if cv['type'] == 'id' %}
                  <th align="left" >
                   <div class="custom-control custom-checkbox">
                      <input type="checkbox"  class="custom-control-input" id="choose-all" name="choose-all">
                      <label class="custom-control-label"  for="choose-all"></label>
                    </div>
                  </th>
                {% endif %}
              {% endfor %}
                {% for k, v in column %}
                    <th align="left">
                        {% if v['sort'] %}
                         {{  knp_pagination_sortable(pagination, k, v['sort']) }}
                        {% else %}
                              {{  k }}
                        {% endif %}</th>
                {% endfor %}
                {% if tableActionCallback %} <th>操作</th> {% endif %}
            </tr>
            </thead>
            <tbody>
            {% for v in list %}
            <tr>
                {% for cv in column %}
                  {% if cv['type'] == 'id' %}
                  <td align="left">
                      {% if array_get(v, 'isLock') %}
                      {% else %}
                      <div class="custom-control custom-checkbox">
                       <input type="checkbox" class="custom-control-input" id="chb{{ get_prop(v, cv["field"], cv['type'], cv['options'])|raw }}" name="ids[]" value="{{ get_prop(v, cv["field"], cv['type'], cv['options'])|raw }}">
                       <label class="custom-control-label" for="chb{{ get_prop(v, cv["field"], cv['type'], cv['options'])|raw }}" ></label>
                      </div>
                      {% endif %}
                  </td>
                  {% endif %}
                {% endfor %}
                {% for cv in column %}
                    <td align="left">
                        {% if cv['type'] == 'text' or cv['type'] == 'datetime' or cv['type'] == 'textarea' %}
                            {{ get_prop(v, cv["field"], cv['type'], cv['options'])|raw }}
                        {% endif %}

                        {% if cv['type'] == 'badgePrimary' %}
                <span class="badge badge-primary">{{ get_prop(v, cv["field"], cv['type'], cv['options'])|raw }}</span>
                        {% endif %}

                        {% if cv['type'] == 'badgeSuccess' %}
                            <span class="badge badge-success">{{ get_prop(v, cv["field"], cv['type'], cv['options'])|raw }}</span>
                        {% endif %}


                        {% if cv['type'] == 'badgeInfo' %}
                            <span class="badge badge-info">{{ get_prop(v, cv["field"], cv['type'], cv['options'])|raw }}</span>
                        {% endif %}

                        {% if cv['type'] == 'badgeWarning' %}
                            <span class="badge badge-warning">{{ get_prop(v, cv["field"], cv['type'], cv['options'])|raw }}</span>
                        {% endif %}

                        {% if cv['type'] == 'badgeDanger' %}
                            <span class="badge badge-danger">{{ get_prop(v, cv["field"], cv['type'], cv['options'])|raw }}</span>
                        {% endif %}

                        {% if cv['type'] == 'badgeDark' %}
                            <span class="badge badge-dark">{{ get_prop(v, cv["field"], cv['type'], cv['options'])|raw }}</span>
                        {% endif %}

                        {% if cv['type'] == 'badgePurple' %}
                            <span class="badge badge-purple">{{ get_prop(v, cv["field"], cv['type'], cv['options'])|raw }}</span>
                        {% endif %}

                        {% if cv['type'] == 'badgePink' %}
                            <span class="badge badge-pink">{{ get_prop(v, cv["field"], cv['type'], cv['options'])|raw }}</span>
                        {% endif %}

                        {% if cv['type'] == 'badgeBrown' %}
                            <span class="badge badge-brown">{{ get_prop(v, cv["field"], cv['type'], cv['options'])|raw }}</span>
                        {% endif %}

                        {% if cv['type'] == 'badgeMuted' %}
                            <span class="badge badge-muted">{{ get_prop(v, cv["field"], cv['type'], cv['options'])|raw }}</span>
                        {% endif %}

                         {% if cv['type'] == 'tip' %}
                            <a title='{{ get_prop(v, cv["field"], cv['type'], cv['options'])|raw }}' class="msgtip" style="color:#e83e8c">
                            {{ get_prop(v, cv["field"], cv['type'], cv['options'])|raw|striptags|substr(0, 20)}}
                            </a>
                        {% endif %}

                        {% if cv['type'] == 'json' %}
                            {{ get_prop(v, cv["field"], cv['type'], cv['options'])|json_encode }}
                        {% endif %}

                        {% if cv['type'] == 'code' %}
                       <div  class='overflow-auto' style='width:300px'><code class="clipboard" data-clipboard-text="{{ get_prop(v, cv["field"], cv['type'], cv['options']) }}" >{{ get_prop(v, cv["field"], cv['type'], cv['options'])|raw }}</code></div>
                        {% endif %}
                        {% if cv['type'] == 'image'  %}
                            {% if get_prop(v, cv['field'], cv['type'], cv['options']) %}
                                <img src="{{  get_prop(v, cv["field"], cv['type'], cv['options'])|raw }}" class="imgpreview" width="30px" />
                            {% endif %}
                        {% endif %}
                        {% if cv['type'] == 'boole' %}
                            {% if get_prop(v, cv['field'], cv['type']) %}
                                <span class="badge bg-success">Y</span>
                            {% else %}
                                <span class="badge bg-danger">N</span>
                            {% endif %}
                        {% endif %}
                        {% if cv['type'] == 'boole2' %}
                            {% if cv['actionCall'] %}
                                {{ get_prop(cv['actionCall'],v)|raw }}
                            {% else %}
                                {% if get_prop(v, cv['field'], cv['type']) %}
                                    <span class="badge bg-success">Y</span>
                                {% else %}
                                    <span class="badge bg-danger">N</span>
                                {% endif %}
                            {% endif %}
                        {% endif %}
                    </td>
                {% endfor %}
                {% if tableActionCallback %}
                    <td align="left">
                        {% for tb in  tableActionCallback %}
                            {{ get_prop(tb, v)|raw }}
                        {% endfor %}
                    </td>
                {% endif %}
            </tr>
                {% else %}
                    <tr>
                        <td colspan="{{ sum(column|length, 1) }}" align="left">暂无数据</td><td></td>
                    </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
  <div class="navigation row" style="margin-bottom: 10px;padding-left: 30px;">
    {% if(bathDelete) %}
      <div class="col-1">
        <a href='javascript:;' data-href="{{ bathDelete|raw }}" data-confirm="确认要删除选择的行吗?" title="删除" class="btn btn-danger btn-xs ajaxBathDelete"><i class="mdi mdi-delete"></i></a>
      </div>
    {% endif %}
    <div class="col-11">
      {{ knp_pagination_render(pagination) }}
    </div>
  </div>
</div>
<script>
$(function(){
    $(".ajaxBathDelete").each(function(){
      var chref = $(this).data("href");
      var isconfirm = $(this).data("confirm");
      $(this).click(function () {
        var params = [];
        $("input[name='ids[]']:checkbox").each(function() {
          if(this.checked){
            var allid = $(this).val();
            params.push(allid);
          }
        })

        if(params.length==0){
          showMsg(400, "请至少选择一行!");
          return ;
        }

        layer.msg(isconfirm, {
            skin:"bg-dark",
          time: 0 //不自动关闭
          , btn: ['是', '否']
          , yes: function (index) {
            layer.close(index);
            requestPost(chref, {"ids":params});
          }
        });
        return false;
      });

    });
});
</script>
